package com.ifox.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Mssql2008 {

	public static void main(String[] args) throws Exception {
		String driverUrl="jdbc:jtds:sqlserver://192.168.1.4:1433;DatabaseName=test;SelectMethod=cursor;UserCursor="; 
		//Char,Varchar,Text,Bigint,Bit,Smallint,Numeric,Float,Date,Datetime,Int
		Class.forName("net.sourceforge.jtds.jdbc.Driver");
		Connection conn = DriverManager.getConnection(driverUrl,"sa","12345678");
		PreparedStatement pstmt2 = conn.prepareStatement("insert into T2 values(?,?,?,?,?,?,?,?,?,?,?,?)");
		String sql = "select * from T1";
		ResultSet rs = conn.prepareStatement(sql).executeQuery();
		while(rs.next()){
			for(int i=1;i<13;i++){
				pstmt2.setObject(i, rs.getObject(i));
			}
			pstmt2.executeUpdate();
			
		}
	}
}
